package org.bitterorange.flansmodslain.listeners;

import com.flansmod.common.eventhandlers.PlayerReviveEvent;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import org.bitterorange.flansmodslain.models.BukkitPlayerReviveEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class PlayerReviveListener {

    @Mod.EventHandler
    @SubscribeEvent
    public void onPlayerRevive(PlayerReviveEvent e) {
        if(e.getReviverName() == null || e.getRevivedName() == null) {
            System.out.println("救援事件属性为空：reviver：" + e.getReviverName() + " revived：" + e.getRevivedName());
            return;
        }
        Player reviver = Bukkit.getPlayer(e.getReviverName());
        Player revived = Bukkit.getPlayer(e.getRevivedName());
        if (reviver != null && revived != null) {
            Bukkit.getServer().getPluginManager().callEvent(new BukkitPlayerReviveEvent(reviver, revived, e.getPosX(), e.getPosY(), e.getPosZ(), e.getWeapon()));
        }
    }
}
